*************************
clear all
set more off
capture log close
set logtype text
cd t:\vega\kilian_vega
set memory 600m
**************************
log using test2, replace
log close

use retail_gas_daily_clean, clear

global numvar=0

*above stata series corresponds to regular retail gas price (including taxes) in us'PUFLPPGRRG_N.B

sort date
save retail_gas_daily_clean, replace


*GDP Advanced, GDP Preliminary, GDP Final, Unemployment Rate, Nonfarm Payroll, Retail Sales, Industrial Production, Capacity Utilization, Personal Income, Consumer Credit, Personal Consumption Expenditures, New Home Sales, Durable Goods Orders, Construnction Spending, Factory Orders, Business Inventories, Government Budget Deficit, Trade Balance, PPI, Core PPI, CPI, Core CPI, Consumer Confidence Index (Board), Consumer Confidence (U. Mich.) Preliminary, Consumer Confidence (U. Mich.) Final , NAPM Index, Housing Starts, Index of Leading Indicators, Target Rate Surprises, Initial Claims
*foreach num of numlist 26 27 28 1 7 9 11 10 19 21 17 18 3 13 15 12 20 6 8 34 2 33 14 71 72 16 4 5 32 25 {
*positive sign
foreach num of numlist 26 27 28 7 9 11 10 19 21 17 18 3 13 15 20 6 8 34 2 33 71 72 14 16 4 5 {

*foreach num of numlist 7 {
	use mms_all_final2, clear
	drop if surs`num'==.
	keep date surs`num'
	keep if date~=.
	sort date

	
	merge date using retail_gas_daily_clean		
	sort date


*No need for the keep command because this is the dataset that starts in 2003.
*keep if year(date)>=2003
	*replace sur`num'=sur`num'[_n-1] if sur`num' ==. & price_ch[_n-1] ==. & price_ch !=.
	*replace surs`num'=surs`num'[_n-1] if surs`num' ==. & price_ch[_n-1] ==. & price_ch !=.


	
	
reg price_ch surs`num', robust
matrix V=e(V)

global dep=e(N)-e(df_r)
global adj_r2=round(e(r2)*100,0.01)
global obs=e(N)
global depname=e(depvar)
global numvar=`num'

global tstat=round(_b[surs`num']/sqrt(V[1,1]),0.01)
*global pneg=1-ttail($obs-1,_b[surs`num']/sqrt(V[1,1]))
global pval=ttail($obs-1,_b[surs`num']/sqrt(V[1,1]))

disp $pval $tstat

do record3.do
}

*negative sign
foreach num of numlist 1 12 32 25 {

*foreach num of numlist 7 {
	use mms_all_final2, clear
	drop if surs`num'==.
	keep date surs`num'
	keep if date~=.
	sort date

	merge date using retail_gas_daily_clean
		
	sort date

*No need for the keep command because this is the dataset that starts in 2003.
*keep if year(date)>=2003
	
	
	
reg price_ch surs`num', robust
matrix V=e(V)

global dep=e(N)-e(df_r)
global adj_r2=round(e(r2)*100,0.01)
global obs=e(N)
global depname=e(depvar)
global numvar=`num'
global tstat=round(_b[surs`num']/sqrt(V[1,1]),0.01)
global pval=1-ttail($obs-1,_b[surs`num']/sqrt(V[1,1]))
*global pval=ttail($obs-1,_b[surs`num']/sqrt(V[1,1]))

disp $pval $tstat
do record3.do
}

matrix results=results26
foreach num of numlist 27 28 1 7 9 11 10 19 21 17 18 3 13 15 12 20 6 8 34 2 33 71 72 14 16 4 5 32 25 {

matrix results=results\results`num'
}

log using test2, replace
matlist results
log close

